<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        let info=[
            {
                name:"tom",
                age:20,
                sex:"男",
                address:"南京"
            },
            {
                name:"alice",
                age:20,
                sex:"女",
                address:"上海"
            },
            {
                name:"coco",
                age:21,
                sex:"男",
                address:"苏州"
            },
            {
                name:"lili",
                age:20,
                sex:"男",
                address:"北京"
            }
        ];
        //使用模板字符串的取值方式，将数据展示在页面上(取值的时候考虑使用循环)
        /*
        <div id="mydiv">
            <p>我的姓名是tom,年龄是20,性别是男,地址是南京</p>
            <p>我的姓名是alice,年龄是20,性别是女,地址是上海</p>
            <p>我的姓名是coco,年龄是21,性别是男,地址是苏州</p>
            <p>我的姓名是lili,年龄是20,性别是男,地址是北京</p>
            
        </div>
        
        */
       var str="";
       for(var i=0;i<info.length;i++){
            str+=`<p>我的姓名是${info[i].name},年龄是${info[i].age},性别是${info[i].sex},地址是${info[i].address}</p>`;
       }
       window.onload=function(){
       
         var mydiv=document.getElementById("mydiv");
         mydiv.innerHTML=str;
       };
    </script>
</head>
<body>
    <div id="mydiv"></div>
</body>
</html>